import request from '@/utils/request'

//  *********企业新增*********
/**   接口名称目录              功能
      listCompany             list
      removeCompany           del
      checkname				  异步验证企业名称和社会代码
      submitAddCompany        add 
      DetailCompany			  detail
      ModifyCompany    		  modify
**/
//list
export  const  listCompany = (search)=>
	request({
		url:'/op/ent/get_ent_list',
		method:'get',
		params: {
            pageSize: search.limit,
            keyWord: search.name,
            pageNo:search.currentPage,
            orderBy:'modify_time desc'
        }  
	})
//del
export  const  removeCompany = (code) =>
	request({
		url:'/op/ent/delete_ent',
		method: 'get',
	    params:{
	        code
	    }   
	})

//标记删除
export  const  removeCompany_badge = (code) =>
	request({
		url:'/op/ent/mark_delete_ent',
		method: 'get',
	    params:{
	        code
	    }   
	})
//取消标记删除 企业
export  const  removeCancel_badge = (code) =>
	request({
		url:'/op/ent/mark_delete_ent_cancel',
		method: 'get',
	    params:{
	        code
	    }   
	})

// 验证企业名或企业统一社会信用代码是否已经存在
export  const  checkname = (operation,name,creditCode,code) =>
	request({
		url:'/op/ent/verify_ent',
		method: 'get',
	    params:{
	    	operation,
	    	name,
	    	creditCode,
	        code
	    }   
	})

// 提交新增表单  查询登陆
export const submitAddCompany = (form,baseform,banklist,filelist) => 
    request({
        url: '/op/ent/create_ent',
        method: 'post',
        data: JSON.stringify({
			bizEnt:{
				entName:form.entName,//企业名称
				creditCode:form.creditCode,//社会信用代码
				regCapital:form.regCapital,//资金
				regAddr:form.regAddr,//注册地址
				legalPersonName:form.legalPersonName,//法人名称
				legalPersonIdc:form.legalPersonIdc,//身份证号
				taxTitle:form.taxTitle,//抬头
				taxNo:form.taxNo,//税号

				entMemberType:form.entMemberType,//会员类型
				showFlag:baseform.showFlag,//官网会员列表展示
				entAccount:baseform.entAccount, //企业账号
				entPwd:baseform.entPwd,//企业密码
				esignStatus:baseform.signState //电子签章
			},
			//企业联系人
			bizEntContactList:baseform.connect,
			//银行账户信息
			bizEntBankList:banklist,
			//相关文件
			bizEntFileList:filelist
        })
    })
//detail
export const  DetailCompany = (code) =>
    request({
		url:'/op/ent/get_ent',
		method:'get',
		params:{
			code
		}
    })
//modify
export const  ModifyCompany = (code,form,baseform,banklist,filelist,bizEntUserCode) => 
    request({
        url: '/op/ent/modify_ent',
        method: 'post',
        data: JSON.stringify({
			bizEnt:{
				code:code,
				entName:form.entName,//企业名称
				creditCode:form.creditCode,//社会信用代码
				regCapital:form.regCapital,//资金
				regAddr:form.regAddr,//注册地址
				legalPersonName:form.legalPersonName,//法人名称
				legalPersonIdc:form.legalPersonIdc,//身份证号
				taxTitle:form.taxTitle,//抬头
				taxNo:form.taxNo,//税号

				entMemberType:form.entMemberType,//会员类型
				showFlag:baseform.showFlag,//官网会员列表展示
				entAccount:baseform.entAccount, //企业账号
				entPwd:baseform.entPwd,//企业密码
				esignStatus:baseform.signState //电子签章
			},
			//企业联系人
			bizEntContactList:baseform.connect,
			//银行账户信息
			bizEntBankList:banklist,
			//相关文件
			bizEntFileList:filelist,
			bizEntUserCode
        })
    })